<?php declare(strict_types=1);


namespace App\Api\V2\Controller\Mechanism;

use App\Api\Controllers\BaseController;
use App\Models\MechanismMerchant;
use App\Traits\ResponseTrait;
use Illuminate\Http\Request;

class MerchantController extends BaseController
{

    use ResponseTrait;

    public function get(Request $request): string
    {
        $store_id = $request->get("store_id", "");
        try {
            if (empty($store_id)) {
                throw new \Exception("店铺ID不能为空");
            }
            $me = MechanismMerchant::query()->where("merchant_id", $store_id)->first();
            $result = [
                "mechanism_id" => ""
            ];
            if (!empty($me)) {
                $result = [
                    "mechanism_id" => $me->mechanism_id
                ];
            }
            return $this->successResponse("ok", $result);
        } catch (\Exception $e) {
            return $this->errorResponse($e->getMessage());
        }
    }

}